package com.gouwudai.gobbs.service.impl;

import org.extremecomponents.table.limit.Limit;

import com.gouwudai.gobbs.common.Constants;
import com.gouwudai.gobbs.common.IPageList;
import com.gouwudai.gobbs.dao.IMasterGradePermissionDAO;
import com.gouwudai.gobbs.pojo.TbbsMasterGradePermission;
import com.gouwudai.gobbs.service.IMasterGradePermissionService;
import com.litt.core.util.ExtremeTableUtil;

public class MasterGradePermissionServiceImpl implements IMasterGradePermissionService
{
	IMasterGradePermissionDAO masterGradePermissionDAO;
	
	public void save(TbbsMasterGradePermission tbbsMasterGradePermission)
	{	
			masterGradePermissionDAO.save(tbbsMasterGradePermission);
	}

	public void delete(Integer Id)
	{
		masterGradePermissionDAO.delete(Id);
	}
	
	public void saveOrUpdate(Integer mgId,Integer permissionCode,Boolean flag)
	{
			masterGradePermissionDAO.saveOrUpdate(mgId,permissionCode,flag);
	}

	/**
	 * List page.
	 * 
	 * @param pageIndex the page index
	 * @param sort the sort
	 * @param cond 查询条件：1-MG_ID，2-PERMISSION_CODE，3-PERMISSION_NAME，4-QUERY_FLAG(0-全部，1-已拥有权限，2-未拥有权限)
	 * @param pageSize the page size
	 * 
	 * @return the i page list
	 */
	public IPageList listPage(String[] cond,int pageIndex,int pageSize,String sort)
	{
		return masterGradePermissionDAO.listPage(cond,pageIndex, pageSize,sort);
	}
	
	public void AutoBindingTable(javax.servlet.http.HttpServletRequest request)
	{
		String[] cond = new String[4];
		cond[0]=request.getParameter("mgId");
		cond[1]=request.getParameter("permissionCode");
		cond[2]=request.getParameter("permissionName");
		cond[3]=request.getParameter("queryFlag");
		
		Limit limit = ExtremeTableUtil.getLimit(request, Constants.DEFAULT_PAGE_SIZE);
		IPageList page = this.listPage(cond,limit.getPage(), limit.getCurrentRowsDisplayed(),ExtremeTableUtil.getSort(limit));
		request.setAttribute("resultList",page.getRsList());
		request.setAttribute("totalRows",page.getTotalSize());
	}

	public void setMasterGradePermissionDAO(
			IMasterGradePermissionDAO masterGradePermissionDAO) {
		this.masterGradePermissionDAO = masterGradePermissionDAO;
	}
	
}